import java.util.Scanner;

public class HihoCoder1501 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num=in.nextInt();
		for(int i=num;i>0;i--){
			String input=in.next();
			changeName(input);
		}
	}

	private static void changeName(String input) {
		if(input.contains("_")){
			snakeCase(input);
		}else{
			camelCase(input);
		}
	}

	private static void camelCase(String input) {
		 byte[] item = input.getBytes();    
		String result="";
		for(int i=0;i<item.length;i++){
			if(item[i]>=97){
				result=result+(char)item[i];
			}else{
				result=result+"_"+(char)(item[i]+32);
			}
		}
		System.out.println(result);
	}

	private static void snakeCase(String value) {
		String[] item=value.split("_");
		for(int i=1;i<item.length;i++){
			item[i]=item[i].substring(0, 1).toUpperCase()+item[i].substring(1);
		}
		String result="";
		for(String i:item){
			result=result+i;
		}
		System.out.println(result);
	}

}
